#ifndef __I_NET_EVENT_LISTENER_H__
#define __I_NET_EVENT_LISTENER_H__

#include "NetConstants.h"
#include "NetPeer.h"
#include "asio.hpp"

namespace LiteNetLib
{
    class NetPeer;
    class ConnectionRequest;

    typedef asio::ip::udp::endpoint net_endpoint;

    enum class DisconnectReason
    {
        ConnectionFailed,
        Timeout,
        HostUnreachable,
        NetworkUnreachable,
        RemoteConnectionClose,
        DisconnectPeerCalled,
        ConnectionRejected,
        InvalidProtocol,
        UnknownHost,
        Reconnect,
        PeerToPeerConnection
    };

    class INetEventListener
    {
    public:
    
        virtual void OnPeerConnected(NetPeerPtr &peer) = 0;

        /**
         * @brief 客户端断开连接
         * @param peer 客户端
         * @param reson 断开原因
         * @param packet
         * @param packetLength
        */
        virtual void OnPeerDisconnected(NetPeerPtr &peer, DisconnectReason reason, const char* packet, uint32_t packetLength) = 0;

        /**
         * @brief 收到客户端的数据
         * @param peer 客户端
         * @param packet 客户端发送过来的数据
         * @param packetLength 客户端发过来的数据的长度
         * @param deliveryMethod 
        */
        virtual void OnNetworkReceive(NetPeerPtr &peer, const char* packet, uint32_t packetLength, DeliveryMethod deliveryMethod) = 0;

        /**
         * @brief 收到未正式连接成的 ip 发送过来的数据
         * @param addr ip 地址
         * @param packet 数据包
         * @param packetLength 数据包长度
         * @param messageType
        */
        virtual void OnNetworkReceiveUnconnected(net_endpoint *endpoint, const char* packet, uint32_t packetLength, UnconnectedMessageType messageType) = 0;

        /**
         * @brief 收到连接请求
         * @param request
        */
        virtual void OnConnectionRequest(ConnectionRequest *request) = 0;
    };
    
} // namespace LiteNetLib

#endif
